package com.dt.platform.generator.module.oa;

import com.dt.platform.constants.db.OaTables;
import com.dt.platform.constants.enums.common.StatusEnableEnum;
import com.dt.platform.constants.enums.oa.SealStatusEnum;
import com.dt.platform.domain.oa.SealInfo;
import com.dt.platform.domain.oa.meta.SealInfoMeta;
import com.dt.platform.domain.oa.meta.SystemInformationMeta;
import com.dt.platform.generator.config.Config;
import com.dt.platform.oa.page.SealInfoPageController;
import com.dt.platform.proxy.oa.SealInfoServiceProxy;
import com.github.foxnic.generator.config.WriteMode;
import org.github.foxnic.web.domain.hrm.Employee;
import org.github.foxnic.web.domain.hrm.Organization;
import org.github.foxnic.web.domain.system.DictItem;
import org.github.foxnic.web.domain.system.meta.DictItemMeta;
import org.github.foxnic.web.proxy.system.DictItemServiceProxy;

public class SeaInfoGtr extends BaseCodeGenerator {

    //DownFileGtr
    public SeaInfoGtr() {
        super(OaTables.OA_SEAL_INFO.$TABLE,"811710244936744961");
    }

    public void generateCode() throws Exception {
        System.out.println(this.getClass().getName());
        cfg.getPoClassFile().addSimpleProperty(Employee.class,"user","user","user");

        cfg.getPoClassFile().addSimpleProperty(DictItem.class,"typeDict","typeDict","typeDict");

        cfg.view().field(OaTables.OA_SEAL_INFO.ID).basic().hidden(true);
        cfg.view().field(OaTables.OA_SEAL_INFO.NAME).search().fuzzySearch();


        cfg.getPoClassFile().addSimpleProperty(Organization.class,"mgrOrg","组织部门","组织部门");
        cfg.getPoClassFile().addSimpleProperty(Organization.class,"owner","主体","主体");

        cfg.view().search().inputLayout(
                new Object[]{
                        OaTables.OA_SEAL_INFO.STATUS,
                        OaTables.OA_SEAL_INFO.TYPE,
                        OaTables.OA_SEAL_INFO.NAME,
                }
        );

        cfg.view().field(OaTables.OA_SEAL_INFO.NOTES).table().disable(true);
        cfg.view().field(OaTables.OA_SEAL_INFO.IMAGE_ID).table().disable(true);
        cfg.view().field(OaTables.OA_SEAL_INFO.UPDATE_BY).table().disable(true);

        cfg.view().field(OaTables.OA_SEAL_INFO.NOTES).table().disable(true);
        cfg.view().field(OaTables.OA_SEAL_INFO.NAME).form().validate().required();
        cfg.view().field(OaTables.OA_SEAL_INFO.STATUS).form().radioBox().enumType(SealStatusEnum.class).defaultIndex(0);
        cfg.view().field(OaTables.OA_SEAL_INFO.IMAGE_ID).form().upload().maxFileCount(3);

        cfg.view().search().labelWidth(1,Config.searchLabelWidth);
        cfg.view().search().labelWidth(2,Config.searchLabelWidth);
        cfg.view().search().labelWidth(3,Config.searchLabelWidth);
        cfg.view().search().labelWidth(4,Config.searchLabelWidth);
        cfg.view().search().inputWidth(Config.searchInputWidth);

        cfg.view().formWindow().bottomSpace(80);
        cfg.view().formWindow().width(Config.baseFormWidth);


        cfg.view().field(OaTables.OA_SEAL_INFO.TYPE)
                .basic().label("印章类型")
                .form().validate().required().form().selectBox().queryApi(DictItemServiceProxy.QUERY_LIST+"?dictCode=oa_seal_type")
                .paging(false).filter(false).toolbar(false)
                .valueField(DictItemMeta.CODE).
                textField(DictItemMeta.LABEL).
                fillWith(SealInfoMeta.TYPE_DICT).muliti(false);


        cfg.view().field(OaTables.OA_SEAL_INFO.OWNER_ID)
                .form().validate().required().form().button().chooseCompany(true);
        cfg.view().field(OaTables.OA_SEAL_INFO.OWNER_ID).table().fillBy("owner","fullName");




        cfg.view().field(OaTables.OA_SEAL_INFO.MGR_ORG_ID)
                .form().button().chooseOrganization(true);
        cfg.view().field(OaTables.OA_SEAL_INFO.MGR_ORG_ID).table().fillBy("mgrOrg","fullName");


        cfg.view().field(OaTables.OA_SEAL_INFO.MGR_USER_ID).table().fillBy("user","name");
        cfg.view().field(OaTables.OA_SEAL_INFO.MGR_USER_ID).form()
                .button().chooseEmployee(true);



        cfg.view().form().addGroup(null,
                new Object[] {
                        OaTables.OA_SEAL_INFO.NAME,
                        OaTables.OA_SEAL_INFO.STATUS,
                        OaTables.OA_SEAL_INFO.TYPE,
                },
                new Object[] {
                        OaTables.OA_SEAL_INFO.OWNER_ID,
                        OaTables.OA_SEAL_INFO.MGR_ORG_ID,
                        OaTables.OA_SEAL_INFO.MGR_USER_ID,
                }
        );

        cfg.view().form().addGroup(null,
                new Object[] {
                        OaTables.OA_SEAL_INFO.IMAGE_ID,
                        OaTables.OA_SEAL_INFO.NOTES,

                }
        );


        //文件生成覆盖模式
        cfg.overrides()
                .setServiceIntfAnfImpl(WriteMode.IGNORE) //服务与接口
                .setControllerAndAgent(WriteMode.IGNORE) //Rest
                .setPageController(WriteMode.COVER_EXISTS_FILE) //页面控制器
                .setFormPage(WriteMode.COVER_EXISTS_FILE) //表单HTML页
                .setListPage(WriteMode.COVER_EXISTS_FILE)
                .setExtendJsFile(WriteMode.IGNORE); //列表HTML页
        //列表HTML页
        //生成代码
        cfg.buildAll();
    }

    public static void main(String[] args) throws Exception {
        SeaInfoGtr g=new SeaInfoGtr();
        //生成代码
        g.generateCode();

        //移除之前生成的菜单，视情况执行
//        g.removeByBatchId("471622036347682816");
        //生成菜单
       // g.generateMenu(SealInfoServiceProxy.class, SealInfoPageController.class);
    }

}
